﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.Odbc;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class V2Controls_Top10Video : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int Topcount = 0;

        Table Tbl = new Table();
        TableRow TrTop = new TableRow();
        TableCell TdTop = new TableCell();
        Tbl.CellPadding = 0;
        Tbl.CellSpacing = 0;
        Tbl.BorderColor = System.Drawing.Color.Black;
        Tbl.BorderWidth = 1;
        Tbl.BorderStyle = BorderStyle.Solid;
        TdTop.CssClass = "TD_red";
        TdTop.Text = "&nbsp;Nyeste Videoer";
        TrTop.Cells.Add(TdTop);
        Tbl.Rows.Add(TrTop);

        OdbcDataReader MyReader = ReviewerOdbc.Read("SELECT V2_Spil.Titel, V2_Spil.SpilID, V2_SpilVideo.Link, V2_SpilVideo.Titel, V2_SpilVideo.ID FROM V2_SpilVideo JOIN V2_Spil ON V2_Spil.SpilID = V2_SpilVideo.SpilID GROUP BY V2_Spil.SpilID ORDER BY V2_SpilVideo.ID DESC LIMIT 10");
        string Titel;
        string LinkRemake = "";
        while (MyReader.Read())
        {
            Topcount++;
            DateFromMySql DateHandler = new DateFromMySql();
            Titel = MyReader[0].ToString();
            LinkRemake = UI.LinkMake.LinkVideo(MyReader[4].ToString(), MyReader[0].ToString() + " " + MyReader[3].ToString());
            if (Titel.Length > 30)
            {
                Titel = Titel.Substring(0, 30) + "...";
            }
            TableRow Tr2 = new TableRow();
            TableCell Td2 = new TableCell();
            Td2.Text = "<a href=\"" + LinkRemake + "\" style=\"color:black;\">" + MyReader[0].ToString() + "<br />" + MyReader[3].ToString() + "</a>";
            Td2.CssClass = "TD_Top10";
            Td2.VerticalAlign = VerticalAlign.Top;
            Tr2.Cells.Add(Td2);
            Tbl.Rows.Add(Tr2);
        }

        Top10Holder.Controls.Add(Tbl);
    }
}
